package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class Answer extends BaseDomain{

    private User user; // 回答用户

    private Question question; // 回答的问题

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime; // 回答时间

    private String content; // 回答内容

    private int commentCount; // 评论数量

    private Boolean golden; // 是否金牌

    private int likes; // 被顶数量

    private int favs; // 收藏数量

    public String getJson(){
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", this.id);
        map.put("golden", this.golden);
        map.put("content", this.content);
        return JSONUtils.toJSONString(map);
    }

}